package com.cvmars.jianyou.module.activity;

import android.os.Bundle;
import android.text.TextUtils;
import android.widget.Button;
import android.widget.EditText;

import com.cvmars.jianyou.R;
import com.cvmars.jianyou.api.api.Api;
import com.cvmars.jianyou.api.api.HttpUtils;
import com.cvmars.jianyou.api.api.SimpleSubscriber;
import com.cvmars.jianyou.api.model.HttpResult;
import com.cvmars.jianyou.model.UserModel;
import com.cvmars.jianyou.module.base.BaseActivity;
import com.cvmars.jianyou.utils.ToastUtils;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class AdviceActivity extends BaseActivity {

    @BindView(R.id.txt_advice)
    EditText txtAdvice;
    @BindView(R.id.txt_register_btn)
    Button txtRegisterBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_advice_activity);
        ButterKnife.bind(this);
    }

    @OnClick(R.id.txt_register_btn)
    public void onViewClicked() {

        String content = txtAdvice.getText().toString();

        if (TextUtils.isEmpty(content)) {

            ToastUtils.show("内容不能为空");
            return;
        }
        HttpUtils.getInstance().toSubscribe(Api.getInstance().postFeedback(content)
                , new SimpleSubscriber<HttpResult<Object>>() {
                    @Override
                    protected void _onNext(HttpResult<Object> o) {

                        ToastUtils.show(o.getMsg());
                        finish();
                    }

                    @Override
                    protected void _onError(String message) {

                    }
                });

    }
}
